//
//  ForMyCommentCell.m
//  diaoyuren
//
//  Created by 钓鱼人 on 16/4/20.
//  Copyright © 2016年 game. All rights reserved.
//

#import "ForMyCommentCell.h"
#import "TYAttributedLabel.h"

@interface ForMyCommentCell ()<TYAttributedLabelDelegate>
@property (weak, nonatomic) IBOutlet UIButton *userHead;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *headHeight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *headWidth;
@property (weak, nonatomic) IBOutlet MBButtonWithFontAdapter *userName;
@property (weak, nonatomic) IBOutlet MBLabelWithFontAdapter *time;
@property (weak, nonatomic) IBOutlet MBButtonWithFontAdapter *click;
@property (weak, nonatomic) IBOutlet MBLabelWithFontAdapter *title;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *iamgeHeight;
@property (weak, nonatomic) IBOutlet UILabel *footShow;

@property (weak, nonatomic) IBOutlet TYAttributedLabel *content;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *contentHeight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *footHight;
@property (weak, nonatomic) IBOutlet UIImageView *backImage;

@end

@implementation ForMyCommentCell

- (void)awakeFromNib {
    self.selectionStyle = 0;
    self.footShow.backgroundColor = tabPlainBackColor;
    self.footHight.constant = SCREEN_HEIGHT*0.03;
    
    self.headHeight.constant = SCREEN_WIDTH*0.07;
    self.headWidth.constant = self.headHeight.constant;
    radius(self.userHead, self.headHeight.constant/2);
    
    self.click.layer.borderColor = mainColor.CGColor;
    self.click.layer.borderWidth = 0.5;
    
    
    self.backImage.image = [[UIImage imageNamed:@"bg_word"]stretchableImageWithLeftCapWidth:0 topCapHeight:10];
    
    
    [self.userHead sd_setImageWithURL:[NSURL URLWithString:@"http://gtb.baidu.com/HttpService/get?p=dHlwZT1pbWFnZS9qcGVnJm49dmlzJnQ9YWRpbWcmYz10YjppZyZyPTIxODYwNDk3NjYsNDIwMjU2MjQxNwAAAA=="] forState:UIControlStateNormal];
    [self.userName setTitle:@"用户名" forState:UIControlStateNormal];
    
    self.content.backgroundColor = [UIColor clearColor];
    
    NSString *text = @"评论了你的帖子\n收益匪浅";
    
    NSArray *textArray = [text componentsSeparatedByString:@"\n"];
    
    NSArray *colorArray = @[[UIColor lightGrayColor],textcolor];
    
    NSInteger index = 0;
    
    for (NSString *text in textArray) {
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:text];
        
        // 设置当前文本颜色
        [attributedString addAttributeTextColor:colorArray[index%5]];
        
        // 设置当前文本字体
        [attributedString addAttributeFont:[UIFont systemFontOfSize:SCREEN_WIDTH*0.045]];
        self.content.characterSpacing = 2;
        // 追加(添加到最后)属性文本
        [self.content appendTextAttributedString:attributedString];
        [self.content appendText:@"\n"];
        index++;
    }

    [self.content sizeToFit];
    
    self.content.preferredMaxLayoutWidth = SCREEN_WIDTH-40;
 CGFloat Hhhh = [self.content getHeightWithWidth:SCREEN_WIDTH-40];
    
    self.contentHeight.constant = Hhhh;
    
    
    self.iamgeHeight.constant = Hhhh+30;
    self.cellHight = Hhhh+SCREEN_HEIGHT*0.25;

}

- (IBAction)spaceGo:(UIButton *)sender {
    
    
}

- (IBAction)replay:(MBButtonWithFontAdapter *)sender {
    
    
}


-(void)drawRect:(CGRect)rect{
    [super drawRect:rect];


}


@end